package com.liu.repository;

import com.liu.domain.dm;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * Created by liu on 17-9-21.
 */
public interface DmRepository extends JpaRepository<dm,Integer> {

    @Query("select d from dm d where d.dm_id = ?1")
    public dm findById(Integer dm_id);                   //通过id查询


    public List<dm> findByName(String name);            //通过姓名查询

    @Query("select d from dm d where d.build_id = ?1")
    public List<dm> findByBuild(Integer build_id);             //通过楼栋查询

    @Query("select s from dm s where s.dm_id = ?1 and s.password = ?2")  //系统管理员登录
    dm login(int userName, String password);

}
